package edu.mju.commonutils;

import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/**
 * 数据加密
 * @Author:wyp
 * @Date:2020/5/12 10:01
 */
public class EncryptUtil {
    public static String md5(String plainText){
        String ret = null;
        try {
            byte[] secretBytes = MessageDigest.getInstance("md5").digest(plainText.getBytes());
            String md5Val = new BigInteger(1, secretBytes).toString(16);
            for (int i = 0; i < 32 - md5Val.length(); i++) {
                md5Val = "0" + md5Val;
            }
            ret = md5Val;
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }
        return ret;
    }

}
